﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbstractFactory.Table
{
    internal class TableTray : Tray
    {
        public TableTray(string caption) : base(caption)
        {
        }

        public override string MakeHtml()
        {
            var buffer = new StringBuilder();
            buffer.Append("<td>");
            buffer.Append("<table width=\"100%\" border=\"1\"><tr>");
            buffer.Append($"<td bgcolor=\"#cccccc\" align=\"center\" colspan=\"{tray.Count}\"><b>{caption}</b></td>");
            buffer.Append("</tr>\n");
            buffer.Append("<tr>\n");
            foreach (var item in tray)
            {
                buffer.Append(item.MakeHtml());
            }
            buffer.Append("</tr></table>\n");
            buffer.Append("</td>");
            return buffer.ToString();
        }
    }
}
